#!/bin/bash



GREP_PROCESS="generate_instruction_multiprocess.py"

##################### restart server #############################
PID_RANK=`ps -ef|grep "$GREP_PROCESS"|grep -v grep|awk '{print $2}'|xargs`
if [  "$PID_RANK" != "" ];then
    echo "-----Force kill current generate process"
    kill -9 $PID_RANK
fi

export OPENAI_API_KEY=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
for i in $(seq 1 1 10);
do
nohup python3 generate_instruction_multiprocess.py generate_instruction_following_data \
  --api=chat --model_name=gpt-3.5-turbo --output_file_name="output/insurance_planner_multi/lingxi.train.insurance_planner_${i}.json" >> "output${i}.out" &
done

################## check if server startup ##########################
PID_RANK=`ps -ef|grep "$GREP_PROCESS"|grep -v grep|awk '{print $2}'`

if [  "$PID_RANK" == "" ];then
    echo "startup fail please check log file."
    exit 1
fi

echo "startup service success!!!"



